<?php
	require_once $_SERVER['DOCUMENT_ROOT'] . '/deviantpic/inc/database.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/deviantpic/inc/profile.php';

	//Get session user and check permission
	$has_permission = FALSE;
	if (isset($_SESSION['user'])) {
		$admin	= NULL;
		$admin_result = mysql_query("SELECT * FROM users WHERE id=" . $_SESSION['user']) or die(mysql_error());
		if (mysql_num_rows($admin_result) >= 1) $admin = mysql_fetch_array($admin_result);
		if ($admin['role']==1) $has_permission = TRUE;
	}

	require_once $_SERVER['DOCUMENT_ROOT'] . '/deviantpic/inc/doctype.php';
?>

			<h3> Admin Control Panel</h3>
			
			<!-- Admin Information Callback -->
			<?php 
				//if there is action
				if (isset($_SESSION['admin_action_ensues'])) {
					echo '<div id="admin-action"> '. $_SESSION['action_content'] .' </div>';
				}
			?>

			<!-- Control Panel Holder -->
			<?php 
				//Check permission
				if (!$has_permission) echo '<div id="admin-cannot-view"> You do not have permission required to view this page. Go to hell. </div>';
				else {
					echo '
						<div id="cp-holder">
							<div class="admin-form-holder">
								<form action="index.php?id='. $_SESSION['user'] .'" method="post">
									<!-- Header -->
									<div class="admin-form-header"> Reset User Password </div>
									<div class="admin-form-information"> Enter the user ID accordingly. </div>
												
									<!-- Content input -->
									<input type="text"  class="admin-input-text" name="reset-pass"/>
								
									<!-- Button -->
									<input type="submit" value="Reset!" />
								</form> 
							</div>
							
							<div class="admin-form-holder">
								<form action="index.php?id='. $_SESSION['user'] .'" method="post">
									<!-- Header -->
									<div class="admin-form-header"> Block User </div>
									<div class="admin-form-information"> Enter the user ID accordingly. </div>
												
									<!-- Content input -->
									<input type="text"  class="admin-input-text" name="block-user"/>
								
									<!-- Button -->
									<input type="submit" value="Block!" />
								</form> 
							</div>
							
							<div class="admin-form-holder">
								<form action="index.php?id='. $_SESSION['user'] .'" method="post">
									<!-- Header -->
									<div class="admin-form-header"> Delete User Photo </div>
									<div class="admin-form-information"> Enter the photo ID accordingly. </div>
												
									<!-- Content input -->
									<input type="text"  class="admin-input-text" name="delete-photo"/>
								
									<!-- Button -->
									<input type="submit" value="Delete!" />
								</form> 
							</div>
						</div>
				';}
			?>
